package org.topteam.dao.demo;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.topteam.dao.BaseDao;
import org.topteam.domain.demo.Todo;

@Repository
public class TodoDao extends BaseDao {

	@Autowired
	public TodoDao(@Qualifier("sessionFactory") SessionFactory sf) {
		super(sf);
	}

	public List<Todo> getTodos(int page, int size) throws Exception {
		String hql = "select t from Todo t order by t.doneDate ";
		return this.findPageByHQL(hql, page, size);
	}

	public long getTodoCount() throws Exception {
		String hql = "select count(t) from Todo t";
		return this.findCountByHQL(hql);
	}

}
